function setCookie(cookieName,cookievalue,day){

    var json ={
        cookieName:cookievalue
    }

    var jsonStr =JSON.stringify(json);

    var str =cookieName+"="+jsonStr;
    if(day){
        var date = new Date();
        date.setDate(date.getDate()+day);
        str+=";expires="+date.toGMTString();
    }

    document.cookie= str;

}

function getCookie(cookieName){
    var str = document.cookie;

    var arr = str.split("; ");

    for(var i=0;i<arr.length;i++){
        var temp =arr[i];

        var index = temp.indexOf("=");
        var key = temp.substring(0,index);
        var value = temp.substring(index+1);

        if(cookieName==key){
            var json =JSON.parse(value);
            return json.cookieName;
        }
    }



}